import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: '字典编码',
    key: 'dictCode',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '字典标签',
    key: 'dictLabel',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '字典键值',
    key: 'dictValue',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '排序',
    key: 'dictSort',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '字典类型',
    key: 'dictType',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '样式属性',
    key: 'cssClass',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '表格回显样式',
    key: 'listClass',
    fieldType: TableFieldType.TEXT,
    display: false,
  },
  {
    title: '是否默认',
    key: 'isDefault',
    fieldType: TableFieldType.TAG,
    tagOptions: {
      options: [
        {
          label: '是',
          value: 'Y',
          type: 'success',
        },
        {
          label: '否',
          value: 'N',
          type: 'error',
        },
      ],
    },
  },
  {
    title: '备注',
    key: 'remark',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '创建时间',
    key: 'createTime',
    fieldType: TableFieldType.TEXT,
  },
];

export const formSchemas: FormSchema[] = [
  {
    field: 'dictCode',
    component: FormFieldType.INPUT,
    label: 'dictCode',
    display: false,
  },
  {
    field: 'dictLabel',
    component: FormFieldType.INPUT,
    label: '字典标签',
    rules: [{ required: true }],
  },
  {
    field: 'dictValue',
    component: FormFieldType.INPUT,
    label: '字典键值',
    rules: [{ required: true }],
  },
  {
    field: 'dictType',
    component: FormFieldType.INPUT,
    label: '字典类型',
    rules: [{ required: true }],
  },
  {
    field: 'dictSort',
    component: FormFieldType.INPUT_NUMBER,
    label: '排序',
  },
  {
    field: 'cssClass',
    component: FormFieldType.INPUT,
    label: '样式属性',
  },
  {
    field: 'listClass',
    component: FormFieldType.SELECT,
    label: '回显样式',
    componentProps: {
      options: [
        {
          label: '默认',
          value: 'default',
        },
        {
          label: '主要',
          value: 'primary',
        },
        {
          label: '成功',
          value: 'success',
        },
        {
          label: '信息',
          value: 'info',
        },
        {
          label: '警告',
          value: 'warning',
        },
        {
          label: '错误',
          value: 'danger',
        },
      ],
      valueField: 'value',
    },
  },
  {
    field: 'isDefault',
    component: FormFieldType.RADIO_GROUP,
    label: '默认',
    componentProps: {
      options: [
        {
          label: '是',
          value: 'Y',
        },
        {
          label: '否',
          value: 'N',
        },
      ],
    },
    defaultValue: 'N',
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
    giProps: {
      span: 2,
    },
  },
];

export const dictionaryTypeFormSchemas: FormSchema[] = [
  {
    field: 'dictId',
    component: FormFieldType.INPUT,
    label: 'dictId',
    display: false,
  },
  {
    field: 'dictName',
    component: FormFieldType.INPUT,
    label: '字典名称',
    rules: [{ required: true }],
  },
  {
    field: 'dictType',
    component: FormFieldType.INPUT,
    label: '字典类型',
    rules: [{ required: true }],
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
  },
];
